﻿using System;

namespace IupNET
{
    public class Text:EditBase
    {
       
        

        public Text()
            : base(Iupc.Text(null))
        {
            

        }

        public Alignment Alignment
        { 
            get
            {
                return Convert.StringToAlign(GetAttribute("ALIGNMENT"));
            }
            set
            {
                SetAttribute("ALIGNMENT", Convert.AlignToString(value));
            }
        }

        

        public bool Border
        {
            get
            {
                return GetAttribute("BORDER") == "YES";
            }
            set
            {
                SetAttribute("BORDER", value ? "YES" : "NO");
            }
        }

        public bool CanFocus
        {
            get
            {
                return GetAttribute("CANFOCUS") == "YES";
            }
            set
            {
                SetAttribute("CANFOCUS", value ? "YES" : "NO");
            }
        }

       

       

        //hint: some clipboard options left out for now
        //hint: quebanner ignored, works on to few platforms, not even all windows

        public bool DragDrop
        {
            get
            {
                return GetAttribute("DRAGDROP") == "YES";
            }
            set
            {
                SetAttribute("DRAGDROP", value ? "YES" : "NO");
            }
        }

        public bool Formatting
        {
            get
            {
                return GetAttribute("DRAGDROP") == "YES";
            }
            set
            {
                SetAttribute("DRAGDROP", value ? "YES" : "NO");
            }
        }

        

       

        public bool Multiline
        {
            get
            {
                return GetAttribute("MULTILINE") == "YES";
            }
            set
            {
                SetAttribute("MULTILINE", value ? "YES" : "NO");
            }
        }

        

        public bool Overwrite
        {
            get
            {
                return GetAttribute("OVERWRITE") == "ON";
            }
            set
            {
                SetAttribute("OVERWRITE", value ? "ON" : "OFF");
            }
        }

       

        public bool Password
        {
            get
            {
                return GetAttribute("PASSWORD") == "YES";
            }
            set
            {
                SetAttribute("PASSWORD", value ? "YES" : "NO");
            }
        }

        
        public Scrollbar Scrollbar
        {
            get
            {
                return Convert.StringToScrollbar(GetAttribute("SCROLLBAR"));
            }
            set
            {
                SetAttribute("SCROLLBAR", Convert.ScrollbarToString(value));
            }
        }

       
        

        public bool Spin
        {
            get
            {
                return GetAttribute("SPIN") == "YES";
            }
            set
            {
                SetAttribute("SPIN", value ? "YES" : "NO");
            }
        }

        public int SpinValue
        {
            get
            {
                return Convert.StringToInt(GetAttribute("SPINVALUE"));
            }
            set
            {
                SetAttribute("SPINVALUE", value.ToString());
            }
        }
        
        public int SpinInc
        {
            get
            {
                return Convert.StringToInt(GetAttribute("SPININC"));
            }
            set
            {
                SetAttribute("SPININC", value.ToString());
            }
        }

        public int SpinMax
        {
            get
            {
                return Convert.StringToInt(GetAttribute("SPINMAX"));
            }
            set
            {
                SetAttribute("SPINMAX", value.ToString());
            }
        }

        public int SpinMin
        {
            get
            {
                return Convert.StringToInt(GetAttribute("SPINMIN"));
            }
            set
            {
                SetAttribute("SPINMIN", value.ToString());
            }
        }

        public bool SpinWrap
        {
            get
            {
                return GetAttribute("SPINWRAP") == "YES";
            }
            set
            {
                SetAttribute("SPINWRAP", value ? "YES" : "NO");
            }
        }

        public bool SpinAuto
        {
            get
            {
                return GetAttribute("SPINAUTO") == "YES";
            }
            set
            {
                SetAttribute("SPINAUTO", value ? "YES" : "NO");
            }
        }

        public int TabSize
        {
            get
            {
                return Convert.StringToInt(GetAttribute("TABSIZE"));
            }
            set
            {
                SetAttribute("TABSIZE", value.ToString());
            }
        }

        public int VisibleColumns
        {
            get
            {
                return Convert.StringToInt(GetAttribute("VISIBLECOLUMNS"));
            }
            set
            {
                SetAttribute("VISIBLECOLUMNS", value.ToString());
            }
        }

        public int VisibleLines
        {
            get
            {
                return Convert.StringToInt(GetAttribute("VISIBLELINES"));
            }
            set
            {
                SetAttribute("VISIBLELINES", value.ToString());
            }
        }

        public bool WordWrap
        {
            get
            {
                return GetAttribute("SPIN") == "YES";
            }
            set
            {
                SetAttribute("SPIN", value ? "YES" : "NO");
            }
        }

        public bool AppendNewLine
        {
            get
            {
                return GetAttribute("APPENDNEWLINE") == "YES";
            }
            set
            {
                SetAttribute("APPENDNEWLINE", value ? "YES" : "NO");
            }
        }

        public int ConvertXYToPos(int x, int y)
        {
            return Iupc.ConvertXYToPos(cobject, x, y);
        }

        public void ConvertPosToLinCol(int pos, out int lin, out int col)
        {
            Iupc.TextConvertPosToLinCol(cobject, pos, out lin, out col);
        }

        public int ConvertLinColToPos(int lin, int col) 
        {
            int pos;
            Iupc.TextConvertLinColToPos(cobject,lin,col,out pos);
            return pos;
        }

        public EventCallback Action
        {
            get
            {
                return CBHandler.Fetch("ACTION_TEXT");
            }
            set
            {
                CBHandler.Set("ACTION_TEXT", value);
            }
        }

       

        
        public EventCallback MotionCB
        {
            get
            {
                return CBHandler.Fetch("MOTION_CB");
            }
            set
            {
                CBHandler.Set("MOTION_CB", value);
            }
        }


        public EventCallback SpinCB
        {
            get
            {
                return CBHandler.Fetch("SPIN_CB");
            }
            set
            {
                CBHandler.Set("SPIN_CB", value);
            }
        }


    }
}
